import {TLngLatConstructor, LngLat, LngLatOptions } from './LngLat';
import { Overlay } from './OverLay';
import { Point } from './Point';
import { TileLayer } from './TileLayer';
import { Control } from './Control';

import { EventEmitter } from '@angular/core';

export interface TMapConstructor {
  new(el: HTMLElement | string , opt?: MapOptions): TMapInstance;
}

export interface TMapInstance {

  // TODO:如何定义事件
  // click: (event: any) => void;

  // #region drag
  enableDrag(): void;
  disableDrag(): void;
  isDrag(): boolean;
  // #endregion

  // #region scroll wheel zoom
  enableScrollWheelZoom(): void;
  disableScrollWheelZoom(): void;
  isScrollWheelZoom(): boolean;
  // #endregion

  // #region couble click zoom
  enableDoubleClickZoom(): void;
  disableDoubleClickZoom(): void;
  isDoubleClickZoom(): boolean;
  // #endregion

  // #region key board 接受键盘操作
  enableKeyboard(): void;
  disableKeyboard(): void;
  isKeyboard(): boolean;
  // #endregion

  // #region 惯性拖拽
  enableInertia(): void;
  disableInertia(): void;
  isInertia(): boolean;
  // #endregion

   // #region 连续缩放效果
   enableContinuousZoom(): void;
   disableContinuousZoom(): void;
   isContinuousZoom(): boolean;
   // #endregion

   // #region 双指操作缩放
   enablePinchToZoom(): void;
   disablePinchToZoom(): void;
   isPinchToZoom(): boolean;
   // #endregion

   // #region 自动适应容器尺寸变化
   enableAutoResize(): void;
   disableAutoResize(): void;
   // #endregion

  // #region 操作
  getCode(): string;
  // getBounds()
  getCenter(): LngLat;
  // getSize();
  getZoom(): number;
  getDistance(start: LngLat, end: LngLat): number;


  centerAndZoom(lnglat: LngLat, zoom: number);
  panTo(lnglat: LngLat, zoom?: number);
  setZoom(zoom: number);
  zoomIn(): void;
  zoomOut(): void;
  setMinZoom(level: number);
  setMaxZoom(level: number);
  // #endregion 操作

  addOverLay(overlay: Overlay): void;
  removeOverLay(overlay: Overlay): void;

  addLayer(layer: TileLayer): void;

  addControl(control: Control);
  removeControl(control: Control);
  getContainer(): HTMLElement;

  panBy(position: Point);

  addEventListener(event: string, handler: (e: any) => void): void;
  removeEventListener(event: string, handler: () => void): void;

}

export interface MapOptions {
  projection?: string;
  minZoom?: number;
  maxZoom?: number;
  zoom?: number;
  center?: LngLatOptions;
  layers?: Array<TileLayer>;
}
